package com.test.kafka.service;

import com.test.kafka.Dto.MessageDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class Consumer {

    @KafkaListener(topics = "kafka1", groupId = "group1", containerFactory = "consumerFactory1")
    public void consumer1(List<ConsumerRecord<String, MessageDto>> records) {
        log.info("消费" + records.toString());
    }

//    @KafkaListener(topics = "kafka1", containerFactory = "consumerFactory1")
//    public void consumer1(List<ConsumerRecord<String, MessageDto>> messageDto) {
//        log.info("当前线程id " + Thread.currentThread().getId() + "消费信息" + messageDto.toString());
//    }

//    @KafkaListener(topics = "kafka1", containerFactory = "consumerFactory1")
//    public void consumer2(List<ConsumerRecord<String, MessageDto>> messageDto) {
//        log.info("----------------当前线程id " + Thread.currentThread().getId());
//        log.info("2消费信息" + messageDto.toString());
//    }
}
